# -*- coding: utf-8 -*-

import numpy as np
import cv2


fourcc = cv2.VideoWriter_fourcc(*'XVID') #opencv3
#fourcc = cv2.cv.FOURCC('X','V','I','D') #opencv2
#                      保存名字      格式    频率   大小
out = cv2.VideoWriter('output.avi',fourcc, 50.0, (568,320))

i = 0
imgPath = ""

while(True):
  i=i+1
  imgPaht = "D:\\pic\\"+str(i)+".bmp" #---第一种格式化字符串的方法    
  #imgPaht = "E:\\pics\\%s.bmp"%str(i)#---第二种格式化字符串方法
  img = cv2.imread(imgPaht)
  if(img is None):
    break
  cv2.imshow("img", img)
  out.write(img)
  cv2.waitKey(10)

cv2.waitKey(0)
out.release()
cv2.destroyAllWindows()    
print("finish")
